#include<bits/stdc++.h>
#define all(a) a.begin(), a.end()
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using vi32 = std::vector<int>;
using pii32 = std::pair<int, int>;
using vii32 = std::vector<pii32>;
using vi64 = std::vector<i64>;
using pii64 = std::pair<i64, i64>;
using vii64 = std::vector<pii64>;

//std::mt19937 rng {std::chrono::steady_clock::now().time_since_epoch().count()};




int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;
	std::vector g(n + 1, std::vector<int>(n + 1, 0));
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= i; j++) {
			std::cin >> g[i][j];
		}
	}
	int ans = 1;
	for(int i = 1; i <= n; i++) {
		if(ans >= i) {
			ans = g[ans][i];
		} else {
			ans = g[i][ans];
		}
	}
	std::cout << ans;
	
	return 0;
}